package com.zmovie.framework.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zmovie.framework.domain.Actor;
import com.zmovie.framework.service.ActorService;
import com.zmovie.framework.mapper.ActorMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author lenovo
* @description 针对表【actor】的数据库操作Service实现
* @createDate 2023-12-04 21:00:12
*/
@Service
public class ActorServiceImpl extends ServiceImpl<ActorMapper, Actor>
    implements ActorService{
    @Override
    public Page<Actor> pageActor(Integer pageNo, Integer pageSize, Actor actor) {
        Page<Actor> actorPage = new Page<>(pageNo, pageSize);
        LambdaQueryWrapper<Actor> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(actor.getName() != null, Actor::getName, actor.getName());
        wrapper.orderByAsc(Actor::getName).orderByAsc(Actor::getGender);
        return page(actorPage, wrapper);
    }

    @Override
    public List<Actor> listNotIn(List<Integer> actorIds) {
        LambdaQueryWrapper<Actor> wrapper = new LambdaQueryWrapper<>();
        wrapper.notIn(Actor::getId, actorIds);
        wrapper.orderByAsc(Actor::getId);
        return list(wrapper);
    }
}




